package com.zzb.controller;

import com.zzb.DTO.ResultDTO;
import com.zzb.VO.UserVO;
import com.zzb.service.UserService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author ASUS
 */
@RestController
@CrossOrigin
public class LoginController {

    @Resource
    private UserService userService;

    /**
     * 登录
     *
     * @param userVO
     * @param request
     * @return
     */
    @PostMapping("/login")
    public ResultDTO login(UserVO userVO, HttpServletRequest request) {
        //String id = request.getSession().getId();
        String codeKey = request.getParameter("mark");
        return userService.login(userVO, codeKey);
    }

    /**
     * 退出
     *
     * @return
     */
    @PostMapping("/user/logout")
    public ResultDTO logout() {
        return userService.logout();
    }
}